package com.example.parallelandroid;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow;

import com.example.parallelandroid.utils.SPUtils;

public class MyPopupWindow extends PopupWindow implements View.OnClickListener {
    private View mPopView;
    private onYesOnclickListener yesOnclickListener;//确定按钮被点击了的监听器
    int i;
    private int color1,color2,color3,color4,color5,color6,color7,color8,color9,color10,color11,color12;
    private ColorDrawable bg1,bg2,bg3,bg4,bg5,bg6,bg7,bg8,bg9,bg10,bg11,bg12;
    ImageView tou1,tou2,tou3,tou4,tou5,tou6,tou7,tou8,tou9,tou10,tou11,tou12;
    Button cancel,confirm;
    private UpdatePersonActivity context;

    public MyPopupWindow(final UpdatePersonActivity context) {
        // TODO Auto-generated constructor stub
        this.context = context;
        init(context);
        setPopupWindow();

        tou1.setOnClickListener(this);
        tou2.setOnClickListener(this);
        tou3.setOnClickListener(this);
        tou4.setOnClickListener(this);
        tou5.setOnClickListener(this);
        tou6.setOnClickListener(this);
        tou7.setOnClickListener(this);
        tou8.setOnClickListener(this);
        tou9.setOnClickListener(this);
        tou10.setOnClickListener(this);
        tou11.setOnClickListener(this);
        tou12.setOnClickListener(this);
        cancel.setOnClickListener(this);
        confirm.setOnClickListener(this);


    }

    private void init(Context context) {
        LayoutInflater inflater = LayoutInflater.from(context);
        mPopView = inflater.inflate(R.layout.paihang_popupwindow, null);
        cancel = (Button) mPopView.findViewById(R.id.cancel);
        confirm = (Button) mPopView.findViewById(R.id.confirm);
        tou1 = mPopView.findViewById(R.id.tou1);
        tou2 = mPopView.findViewById(R.id.tou2);
        tou3 = mPopView.findViewById(R.id.tou3);
        tou4 = mPopView.findViewById(R.id.tou4);
        tou5 = mPopView.findViewById(R.id.tou5);
        tou6 = mPopView.findViewById(R.id.tou6);
        tou7 = mPopView.findViewById(R.id.tou7);
        tou8 = mPopView.findViewById(R.id.tou8);
        tou9 = mPopView.findViewById(R.id.tou9);
        tou10 = mPopView.findViewById(R.id.tou10);
        tou11 = mPopView.findViewById(R.id.tou11);
        tou12 = mPopView.findViewById(R.id.tou12);
        darkenBackground(0.2f);
    }

    /**
     * 设置窗口的相关属性
     */
    @SuppressLint("InlinedApi")
    private void setPopupWindow() {
        this.setContentView(mPopView);// 设置View
        this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);// 设置弹出窗口的宽
        this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);// 设置弹出窗口的高
        this.setFocusable(true);// 设置弹出窗口可
        this.setAnimationStyle(R.style.DetailAnimation);// 设置动画
        this.setBackgroundDrawable(new ColorDrawable(Color.WHITE));// 设置背景
        this.setOutsideTouchable(true);
        this.setOnDismissListener(new OnDismissListener() { //退出popupwidon时显示父控件原来的颜色
            @Override
            public void onDismiss() {
                WindowManager.LayoutParams lp = context.getWindow().getAttributes();
                lp.alpha = 1.0f;
                context.getWindow().setAttributes(lp);
                darkenBackground(1f);
            }
        });
        mPopView.setOnTouchListener(new View.OnTouchListener() {// 如果触摸位置在窗口外面则销毁
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int height = mPopView.findViewById(R.id.pop_layout).getTop();
                int y = (int) event.getY();
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    if (y < height) {
                        dismiss();
                    }
                }
                return true;
            }
        });
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tou1:
                tou1.setBackgroundColor(Color.BLUE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou2:
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.BLUE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou3:
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.BLUE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou4:
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.BLUE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou5:
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.BLUE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou6:
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.BLUE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou7:
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.BLUE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou8:
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.BLUE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou9:
                tou9.setBackgroundColor(Color.BLUE);
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou10:
                tou10.setBackgroundColor(Color.BLUE);
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou11:
                tou11.setBackgroundColor(Color.BLUE);
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou12.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.tou12:
                tou12.setBackgroundColor(Color.BLUE);
                tou1.setBackgroundColor(Color.WHITE);
                tou2.setBackgroundColor(Color.WHITE);
                tou3.setBackgroundColor(Color.WHITE);
                tou4.setBackgroundColor(Color.WHITE);
                tou5.setBackgroundColor(Color.WHITE);
                tou6.setBackgroundColor(Color.WHITE);
                tou7.setBackgroundColor(Color.WHITE);
                tou8.setBackgroundColor(Color.WHITE);
                tou9.setBackgroundColor(Color.WHITE);
                tou10.setBackgroundColor(Color.WHITE);
                tou11.setBackgroundColor(Color.WHITE);
                bg1 = (ColorDrawable) tou1.getBackground();
                color1 = bg1.getColor();
                bg2 = (ColorDrawable) tou2.getBackground();
                color2 = bg2.getColor();
                bg3 = (ColorDrawable) tou3.getBackground();
                color3 = bg3.getColor();
                bg4 = (ColorDrawable) tou4.getBackground();
                color4 = bg4.getColor();
                bg5 = (ColorDrawable) tou5.getBackground();
                color5 = bg5.getColor();
                bg6 = (ColorDrawable) tou6.getBackground();
                color6 = bg6.getColor();
                bg7 = (ColorDrawable) tou7.getBackground();
                color7 = bg7.getColor();
                bg8 = (ColorDrawable) tou8.getBackground();
                color8 = bg8.getColor();
                bg9 = (ColorDrawable) tou9.getBackground();
                color9 = bg9.getColor();
                bg10 = (ColorDrawable) tou10.getBackground();
                color10 = bg10.getColor();
                bg11 = (ColorDrawable) tou11.getBackground();
                color11 = bg11.getColor();
                bg12 = (ColorDrawable) tou12.getBackground();
                color12 = bg12.getColor();
                break;
            case R.id.confirm:
                if (yesOnclickListener != null) {
                    if (color1 == Color.BLUE){
                        i = 1;
                        //放入缓存
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color2 == Color.BLUE){
                        i = 2;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color3 == Color.BLUE){
                        i = 3;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color4 == Color.BLUE){
                        i = 4;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color5 == Color.BLUE){
                        i = 5;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color6 == Color.BLUE){
                        i = 6;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color7 == Color.BLUE){
                        i = 7;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color8 == Color.BLUE){
                        i = 8;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color9 == Color.BLUE){
                        i = 9;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color10 == Color.BLUE){
                        i = 10;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color11 == Color.BLUE){
                        i = 11;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    if (color12 == Color.BLUE){
                        i = 12;
                        SPUtils.putInt("paihangImg",i,context);
                    }
                    yesOnclickListener.onYesOnclick();

                }
                dismiss();
                break;
            case R.id.cancel:
                dismiss();
                break;
        }
    }

    //确认按钮点击监听
    public void setYesOnclickListener( onYesOnclickListener yesOnclickListener) {
        this.yesOnclickListener = yesOnclickListener;
    }
    public interface onYesOnclickListener {
        public void onYesOnclick();
    }

    private void darkenBackground(Float bgcolor){
        WindowManager.LayoutParams lp = context.getWindow().getAttributes();
        lp.alpha = bgcolor;
        context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        context.getWindow().setAttributes(lp);
    }



}

